//年鉴数据模型，负责获取年鉴数据
import produce from 'immer';
import * as yearbookService from '../services/yearbook';

export default {
  namespace: 'yearbook',
  state: {
    
  },
  reducers: {
    //=================================
    updateState(state, { payload }) {
      return { ...state, ...payload }
    },
    //=================================
  },
  effects: {
    *fetch({ payload: { dataType, statYear }, onComplete }, { call }) {
      const { result, data } = yield call(yearbookService.fetch, { dataType, statYear });
      if (onComplete !== undefined) {
        yield call(onComplete, { result, data });
      }
    }
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname }) => {

      })
    }
  }
}